package com.lqr.wechat.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.bridge.imconfig.base.BaseFragment;
import com.bridge.imconfig.view.CustomDialog;
import com.lqr.imagepicker.ui.ImageGridActivity;
import com.lqr.wechat.R;
import com.lqr.wechat.activity.RedPacketActivity;
import com.lqr.wechat.activity.SessionActivity;
import com.lqr.wechat.activity.TransferActivity;
import com.lqr.wechat.databinding.FragmentFuncPage1Binding;

import static com.lqr.wechat.R.id.tvOne;
import static com.lqr.wechat.R.id.tvTwo;
import static com.lqr.wechat.activity.SessionActivity.IMAGE_PICKER;

/**
 * @创建者 CSDN_LQR
 * @描述 聊天界面功能页面1
 */
public class Func1Fragment extends BaseFragment {

    private View mContentView;
    private CustomDialog mDialog;
    private TextView mTvOne;
    private TextView mTvTwo;
    Intent mIntent;
    private FragmentFuncPage1Binding binding ;

    @Override
    protected int layoutId() {
        return R.layout.fragment_func_page1;
    }

    @Override
    protected void initListener() {
        binding.llPic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIntent = new Intent(getActivity(), ImageGridActivity.class);
                startActivityForResult(mIntent, IMAGE_PICKER);
            }
        });
        binding.llRecord.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((SessionActivity)getActivity()).showPlayVideo();
            }
        });
        binding.llRedPacket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIntent = new Intent(getActivity(), RedPacketActivity.class);
                startActivity(mIntent);
            }
        });
        binding.llTransfer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mIntent = new Intent(getActivity(), TransferActivity.class);
                startActivity(mIntent);
            }
        });
        binding.llLocation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContentView = View.inflate(getActivity(), R.layout.dialog_menu_two_session, null);
                mDialog = new CustomDialog(getActivity(), mContentView, R.style.dialog);
                mDialog.show();
                mTvOne = (TextView) mContentView.findViewById(tvOne);
                mTvTwo = (TextView) mContentView.findViewById(tvTwo);
                mTvOne.setText("发送位置");
                mTvTwo.setText("共享实时位置");
                mTvOne.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mDialog.dismiss();
                    }
                });
                mTvTwo.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mDialog.dismiss();
                    }
                });
            }
        });
        binding.llVideo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContentView = View.inflate(getActivity(), R.layout.dialog_menu_two_session, null);
                mDialog = new CustomDialog(getActivity(), mContentView, R.style.dialog);
                mDialog.show();
                mTvOne = (TextView) mContentView.findViewById(tvOne);
                mTvTwo = (TextView) mContentView.findViewById(tvTwo);
                mTvOne.setText("视频聊天");
                mTvTwo.setText("语音聊天");
                mTvOne.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mDialog.dismiss();
                    }
                });
                mTvTwo.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mDialog.dismiss();
                    }
                });
            }
        });
    }

    @Override
    protected void initView(View view) {
        binding = getBind() ;
    }
}
